package com.zhu.instructions.math;

import com.zhu.instructions.base.NoOperandsInstruction;
import com.zhu.rtda.Frame;
import com.zhu.rtda.OperandStack;

/**
 * 指令：dmul
 *
 * 操作数：无
 *
 * 功能：
 *  将栈顶的两个 double 值相乘：value1 * value2
 *
 * 栈变化：
 *      ..., value1(double), value2(double) → ..., result(double)
 *
 * 示例：
 *  2.5 * 3.0 = 7.5
 *
 * 实现：
 *  使用 * 操作符对两个 double 值进行乘法运算
 */
public class DMUL extends NoOperandsInstruction {
    @Override
    public void execute(Frame frame) {
        OperandStack stack = frame.getOperandStack();
        double v2 = stack.popDouble();
        double v1 = stack.popDouble();
        double result = v1 * v2;
        stack.pushDouble(result);
    }
}
